home *** CD-ROM | disk | FTP | other *** search
- Global Const HIGHEST_TAB = 100
- Global TabStops(-1 To HIGHEST_TAB) As Integer 'tab stops array
- Global NumTabStops As Integer 'number of tab stops in array
-
- Const FOUND_TAB = 1
- Const NO_TAB = 2
-
- 'This routine is called after each file is closed and
- 'all processing for that file is finished.
- Sub AfterAFile ()
- End Sub
-
- 'This routine is called at the very end of the program,
- 'after all files have been processed.
- Sub AfterAllFiles ()
- End Sub
-
- 'The return value of BeforeAFile is usually True, which
- 'indicates that the current file is to be processed
- 'normally. By returning False, you can skip processing
- 'the current file.
- Function BeforeAFile ()
- BeforeAFile = True
- End Function
-
- 'This routine is executed at the very beginning of the
- 'application, before any files are opened or any
- 'processing has taken place.
- Function BeforeAllFiles () As Integer
- APPNAME = "MS-Windows Entabbing Utility"
- TabStops(-1) = 1
- SetTabStops.Show 1
- If SetTabStops.Tag = "CANCEL" Then
- BeforeAllFiles = False
- Else
- BeforeAllFiles = True
- End If
- End Function
-
- Sub CountBlanks (NumBlanks%, Flag%, ByVal i%, TheLine$, t%)
- NumBlanks% = 0
- While Mid$(TheLine$, i%, 1) = " " And i% < TabStops(t%)
- NumBlanks% = NumBlanks% + 1
- i% = i% + 1
- Wend
- If i% = TabStops(t%) Then
- Flag% = FOUND_TAB
- Else
- Flag% = NO_TAB
- End If
- End Sub
-
- 'This routine called over and over, each time being
- 'passed a succeeding line of the file being
- 'processed. Or, in binary mode, this routine is passed
- 'a chunk of bytes as long as RECLEN, except for the
- 'final chunk which may be smaller than RECLEN.
- Function DoALine (TheLine As String) As Integer
- i% = 1 'pointer to the original string
- t% = 0 'index into tabstops array
- TheChar$ = Mid$(TheLine, i%, 1)
- While TheChar$ <> ""
- If TheChar$ = " " Then
- CountBlanks NumBlanks%, Flag%, i%, TheLine, t%
- If Flag% = FOUND_TAB And NumBlanks% > 1 Then
- TheChar$ = Chr$(9)
- i% = i% + NumBlanks%
- Else
- i% = i% + 1
- End If
- NewLine$ = NewLine$ & TheChar$
- Else
- NewLine$ = NewLine$ & TheChar$
- i% = i% + 1
- End If
- TheChar$ = Mid$(TheLine, i%, 1)
-
- 'maintain proper tabstop index
- If i% >= TabStops(t%) Then
- If t% < (NumTabStops - 1) Then
- t% = t% + 1
- End If
- End If
- Wend
- TheLine = NewLine$
- DoALine = True
- End Function
-
-